<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>四则运算函数</title>
	</head>
	<body>
		<input value="计算两数运算结果" type="button" onclick="dianji()" />
		<script>  
		var num1 = parseInt(prompt("请输入第一个数"));
		var num2 = parseInt(prompt("请输入第二个数"));
		var jisuan = prompt("请输入运算符号(+ - * /)");
		var dianji = function(){
			if(isNaN(num1.value) == true || isNaN(num2.value) == true){
			alert("您输入的不是数字")
		}
			if(jisuan=="+"){
				var num3 = eval(num1+num2);
			    alert("两数的运算结果为："+num1+jisuan+num2+'='+num3);
			}else if(jisuan=="-"){
				var num3 = eval(num1-num2);
			    alert("两数的运算结果为："+num1+jisuan+num2+'='+num3);
			}else if(jisuan=="*"){
				var num3 = eval(num1*num2);
			    alert("两数的运算结果为："+num1+jisuan+num2+'='+num3);
			}else if(jisuan=="/"){
				var num3 = eval(num1/num2);
			    alert("两数的运算结果为："+num1+jisuan+num2+'='+num3);
			}
		};	
		</script>
	</body>
</html>
